#include <iostream>
#include "./memory.h"
#include "./leet.h"
using namespace std;
int main()
{
	std::cout<<"TREE"<<std::endl;
	void* root=TestCode::createStruct(TestCode::TREE," [1,-2,3,null,null,4,5]");
	std::cout<<serialize((TreeNode*)TestCode::createStruct(TestCode::TREE,serialize((TreeNode*)root).c_str()))<<std::endl;
	root=TestCode::createStruct(TestCode::TREE,"[]");
	std::cout<<serialize((TreeNode*)root)<<std::endl;
	std::cout<<"LIST"<<std::endl;
	root=TestCode::createStruct(TestCode::LIST,"[]");
	std::cout<<travelList((ListNode*)root)<<std::endl;
	std::cout<<"ARRAY"<<std::endl;
	root=TestCode::createStruct(TestCode::ARRAY," [1 , -2 ,3 ] ");
	std::vector<int>& arr=*(std::vector<int>*)root;
	for(unsigned i=0;i<arr.size();i++)
		std::cout<<arr[i]<<",";
	root=TestCode::createStruct(TestCode::ARRAY," [ [1 , 2,2],[3,4],[2,3],[2,6,7]]");
	root=TestCode::createStruct(TestCode::ARRAY,"[ [1],[3,4],[2,3],[2,-6,7]]");
	std::cout<<std::endl;
	std::vector<std::vector<int>>& arrTwo=*(std::vector<std::vector<int>>*)root;
	for(unsigned i=0;i<arrTwo.size();i++)
	{
		for(unsigned j=0;j<arrTwo[i].size();j++)
			std::cout<<arrTwo[i][j]<<",";
		std::cout<<std::endl;
	}
	std::cout<<"ARRCHAR"<<std::endl;
	root=TestCode::createCharArray(TestCode::STRING," [\" aligned_storage\",\"aligned_storage_t\"]");
	if(root==NULL)
		std::cout<<TestCode::lastError();
	std::vector<std::string>& arrStr=*(std::vector<std::string>*)root;
	for(unsigned i=0;i<arrStr.size();i++)
		std::cout<<arrStr[i]<<std::endl;
	root=TestCode::createCharArray(TestCode::CHAR," [\"1\",\"0\"]");
	std::vector<char>& arrChar=*(std::vector<char>*)root;
	for(unsigned i=0;i<arrChar.size();i++)
		std::cout<<arrChar[i]<<std::endl;
	return 0;
}
